package com.eight.homepage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.eight.common.pojo.TbHeadNav;
import com.eight.common.pojo.TbZone;
import com.eight.common.vo.Result;
import com.eight.homepage.service.TbHeadService;
import com.eight.homepage.service.TbZoneService;
import com.eight.homepage.vo.TbHeadNavVo;
import com.eight.homepage.vo.TbZoneVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 向文豪
 * @program: eight-education-parent
 * @description:
 * @date 2023/5/27 16:17
 */
@RestController
@RequestMapping("/home/head")
@Api(tags = "导航")
public class TbHeadController {

    @Autowired
    private TbHeadService tbHeadService;

    @PostMapping("/getAllHeadNav/{currentPage}/{pageSize}")
    @ApiOperation("分页查询导航标题")
    public Result getAllHeadNav(@PathVariable Integer currentPage, @PathVariable Integer pageSize, @RequestBody TbHeadNavVo tbHeadNavVo){

        Page<TbHeadNav> page = tbHeadService.findPage(currentPage, pageSize, tbHeadNavVo);
        return Result.success(page);
    }

    @PostMapping("/changeStatus/{headId}/{isDisable}")
    @ApiOperation("修改状态")
    public Result changeStatus(@PathVariable Integer headId,@PathVariable String isDisable){
        int i = tbHeadService.updateStatus(headId, isDisable);
        return Result.success();
    }

    @PostMapping("/deleteHeadNav")
    @ApiOperation("删除导航标题")
    public Result delete(@RequestBody TbHeadNav tbHeadNav){
        Integer headId = tbHeadNav.getHeadId();
        int delete = tbHeadService.delete(headId);
        return Result.success();
    }

    @PostMapping("/addHeadNav")
    @ApiOperation("添加导航标题")
    public Result addHead(@RequestBody TbHeadNav tbHeadNav){
        int insert = tbHeadService.insert(tbHeadNav);
        return Result.success();
    }


    @PostMapping("/editHeadNav")
    @ApiOperation("编辑导航标题")
    public Result editHeadNav(@RequestBody TbHeadNav tbHeadNav){
        int i = tbHeadService.updateHead(tbHeadNav);
        return Result.success();
    }
}
